package com.hw.dagl.dao.impl;


import java.sql.ResultSet;
import java.sql.SQLException;

import javax.annotation.Resource;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import com.hw.dagl.model.Sys_Menu;
import com.hw.dao.orm.hibernate.SimpleHibernateDao;
import com.hw.dao.utils.OraclePageDaoBase;
@Repository
public class MenuDaoImpl extends SimpleHibernateDao<Sys_Menu, String>{
	
	@Resource
	private OraclePageDaoBase oraclePageDaoBase;
	/**
	 * 面包屑导航查询
	 * @param menuId 当前菜单ID
	 * @return
	 */
	public String findNavigation(String menuId){
		String sql = "SELECT wm_concat(cd2.cdmc) cdmc FROM ( SELECT *  FROM zdcl_t_cd cd  START WITH cd.cdbs=? CONNECT BY PRIOR cd.sjcdbs =  cd.cdbs ORDER BY to_number(cd.cdbs) ASC )cd2";
		String navStr = oraclePageDaoBase.queryForObject(sql, new RowMapper<String>(){
			@Override
			public String mapRow(ResultSet rs, int arg1) throws SQLException {
				return rs.getString("cdmc");
			}
		}, new Object[]{menuId});
		return navStr;
	}
}
